<?php
/**
 *	@name		商品拍卖
 *	@author		Jeffery
 *	@qq			1017756891
 *	@email		1017756891@qq.com
 *	@website	http://www.iweitao.net
**/

require_once "core.php";

if($core->_get("page")) {
	$page = $core->_get("page");
	$pagecount = $count;
	$page = $page - 1;
	$mulipage = $page*$count;
	$page = $page + 1;
} else {
	$mulipage = 0;
	$page = 1;
	$pagecount = $page*$count;
}
$query = DB::query("SELECT COUNT(*) FROM `".DB::table("paipai_goods")."`");
$fetch = mysql_fetch_array($query);
$getcount = $fetch['COUNT(*)'];
$query = DB::query("SELECT * FROM `".DB::table("paipai_goods")."` ORDER BY `status`  ASC  LIMIT  ". $mulipage .",".$pagecount."");
while($fetch = mysql_fetch_array($query)) {
	$time = time();
	if($fetch['data_end'] > $time) {
		$time = $fetch['data_end'] - $fetch['data_start'];
		$time = $time/24/60/60;
		$time = ceil($time);
		$str = "距交易结束还有&nbsp;".$time."&nbsp;天";
		$newstatus = 'doing';
	} else if($fetch['data_start'] > $time){
		$time = $fetch['data_start'] - $fetch['data_end'];
		$time = $time/24/60/60;
		$time = ceil($time);
		$str = "距离交易开始还有&nbsp;".$time."&nbsp;天";
	} else {
		$newstatus = 'end';
		$str = "交易已经结束，感谢您的关注";
	}
	if($time > $fetch['data_end']) {
		$end = "<button type='button' class='pn' id='checkout' ><strong>结算交易</strong></button>";
	}
	$data_start = date('Y-m-d H:i:s',$fetch['data_start']);
	$data_end = date('Y-m-d H:i:s',$fetch['data_end']);
	$array[] = array(
		'gid' => $fetch['gid'],
		'tid' => $fetch['tid'],
		'uid' => $fetch['uid'],
		'username' => $fetch['username'],
		'type' => $fetch['type'],
		'made' => $fetch['made'],
		'title' => $fetch['title'],
		'price' => $fetch['price'],
		'add_price' => $fetch['add_price'],
		'send' => $fetch['send'],
		'focus' => $fetch['focus'],
		'focus2' => $fetch['focus2'],
		'focus3' => $fetch['focus3'],
		'focus4' => $fetch['focus4'],
		'focus5' => $fetch['focus5'],
		'data_start' => $data_start,
		'data_end' => $data_end,
		'status' => $fetch['status'],
		'str' => $str,
		'newstatus' => $newstatus,
	);
}

$pagestyle = multi($getcount, $count, $page, "plugin.php?id=iweitao_paipai:index", $maxpages = 0, $page = 10, $autogoto = FALSE, $simple = FALSE);
$time = time();
include template("iweitao_paipai:index");
?>